/****************************************************************************
@FILENAME:	ble_packet_send.h
@FUNCTION:	pack ble opcode then send
@AUTHOR:	flege.zhang
@DATE:		2020.04.06
*****************************************************************************/

#ifndef __BLE_PACKET_SEND__H_
#define __BLE_PACKET_SEND__H_


#include "app_cfg.h"
#include "ble_pack_opcode.h"



#define SEND_BEACON_MAX_TIMES							(50)
#define SEND_BEACON_INTERVAL							(10)//10ms
#define SEND_BEACON_CHANNEL								ADV_CHANNEL_BIT_37

/*ROLL CODE*/
#define GROUP_ADDR_ROLL_CODE_BASE						(0x3FE0)

typedef struct
{
	uint8_t para_a;
	uint8_t para_b;
	uint8_t para_c;
	uint8_t para_d;
}str_fun_para;


typedef struct
{
	uint32_t key_value;

	uint32_t short_press_threshold;
	void (*short_press_handler)(str_fun_para*);
	str_fun_para short_press_para;

	uint32_t long_press_threshold;
	void (*long_press_handler)(str_fun_para*);
	str_fun_para long_press_para;
	uint16_t pack_adv_interval;

	uint32_t stop_press_threshold;
}str_key_fun;

typedef struct
{
	//system used,1 words
	uint8_t 	sys_reset_cause;
	uint8_t 	current_group_index;
	uint16_t 	tx_count;

	uint16_t 	rand_seed;
	uint16_t 	rfu;
}str_retention_memory;


void SET_GROUP_INDEX(uint8_t new_group_index);
uint8_t GET_GROUP_INDEX();

void 	ble_packet_init(void);
uint8_t ble_packet_send(void);

#endif

